package cn.com.ejiakanghu.core.rabbitmq;


import cn.com.ejiakanghu.core.config.DirectExchangeRabbitMQConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wj
 * @date 2021/10/19 13:46
 */
@Component
public class DirectExchangeProducer {
    private Logger logger = LoggerFactory.getLogger(DirectExchangeProducer.class);

    @Resource
    private AmqpTemplate amqpTemplate;

    public Object send(String msg, String routingKey) {
        logger.info("litemall消息队列发送消息：{}",msg);
       Object obj=amqpTemplate.convertSendAndReceive(DirectExchangeRabbitMQConfig.DIRECT_EXCANGE_NAME, routingKey, msg);
        logger.info("litemall消息队列返回值为：{}",obj);
        return obj;
    }

}
